<div id="register" class="login_wrapper">
	<div class="animate form login_form">
		<section class="login_content">
			<form action="javascript:void(0);">
				<h1>*** 管理系统注册</h1>
				<div>
					<input
						type="text"
						v-model="user.userName"
						class="form-control"
						placeholder="User Name"
						required=""
					/>
				</div>
				<div>
					<input type="text" v-model="user.email" class="form-control" placeholder="User Email" required="" />
				</div>
				<div>
					<input
						type="password"
						v-model="user.password"
						class="form-control"
						placeholder="Password"
						required=""
					/>
				</div>
				<div>
					<a @click="register()" class="btn btn-default submit" href="javascript:void(0);">Register</a>
					<a class="reset_pass" href="#">Lost your password?</a>
				</div>

				<div class="clearfix"></div>

				<div class="separator">
					<p class="change_link">
						<a href="/login" class="to_register"> Login in </a>
					</p>

					<div class="clearfix"></div>
					<br />

					<div>
						<h1><i class="fa fa-paw"></i> Java_Spring_Boot</h1>
						<p>©2022 All Rights Reserved. Using is a Bootstrap 3 template.</p>
					</div>
				</div>
			</form>
		</section>
	</div>
</div>
<script>
	var registerVue = new Vue({
		el: "#register",
		data: {
			user: {
				userName: "",
				email: "",
				password: "",
				rememberMe: false,
				verificationCode: "",
			},
		},
		methods: {
			register: function () {
				if (this.user.userName == "" || this.user.password == "" || this.user.email == "") {
					layer.msg("Please input register info.", { icon: 0 });
					return;
				}

				console.log(this.user);

				var self = this;
				$.ajax({
					url: "/api/web/user",
					type: "post",
					contentType: "application/json",
					data: JSON.stringify(self.user),
					success: function (rs) {
						if (rs.status == 200) {
							window.location.href = "/test/index";
						} else {
							layer.msg(rs.message, { icon: 0 });
						}
					},
					error: function (data) {
						layer.alert(data.responseText, { icon: 0 });
					},
				});
			},
		},
	});
</script>
